const app = getApp();
const wxApi = app.globalData.wxApi;
const resultMap = {
  fail: {
    icon: '/images/common/pay-fail.png',
    info: '支付失败',
    reason: '',
    optionText: '返回',
    mark: 'fail'
  },
  success: {
    icon: '/images/common/pay-succeed.png',
    info: '支付成功',
    reason: '',
    optionText: '前往查看',
    mark: 'success'
  }
}
Page({
  data: {
    result: resultMap.success
  },
  onLoad( options ) {
    this.init( options );
  },
  init( options ) {
    let type = options.type;
    this.backCount = options.backCount || 2;
    this.setData({
      result: resultMap[ type ] || resultMap.success
    })
  },
  onBack() {
    let pages = getCurrentPages();
    let booksPage = pages[1];
    let bookDetailPage = pages[2];
    booksPage.needRefresh = true;
    bookDetailPage.needRefresh = true;
    wx.navigateBack({
      delta: this.backCount
    })
  }
}) 